class MakeController < ApplicationController
  def step_1
    if params[:id].nil?
      redirect_to '/'
    end
    @skills = @user.dish_skills
    @stove_num = params[:id]
  end

  def step_2
    if params[:skill_id].nil?
      step_1
    end
    begin
      @choosed_dish = @user.dish_skills.find(params[:skill_id]).base_dish
    rescue
      @choosed_dish = BaseDish.find(1)   #TODO:fix
    end
    @stove_num = params[:stove_num]
    @base_dish_id = @choosed_dish.id
    #TODO: Find all dish_skills and list their names, using :join
  end

  def step_3
    base_dish = BaseDish.find(params[:base_dish_id])
    Dish.create(
      :user_id => @user.id,
      :stove_num =>  params[:stove_num],
      :base_dish_id => params[:base_dish_id],
      :amount_rest => base_dish.amount,
      :status => 'in_the_kitchen',
      :completed_at => (Time.now + 10.minutes).to_db_time
    )
    redirect_to home_path()
  end


end
